package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.NewsAuthDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import jdk.nashorn.internal.objects.annotations.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {
    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmNewsPageReqDto dto) {
        return wmNewsService.findList(dto);
    }

    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto) {
        return wmNewsService.submitNews(dto);
    }

    @GetMapping("/one/{id}")
    public ResponseResult findOne(@PathVariable("id") Integer id) {
        return wmNewsService.findOne(id);
    }
    @GetMapping("del_news/{id}")
    public ResponseResult deleteNews(@PathVariable("id") Integer id){
        return wmNewsService.deleteNews(id);
    }
    @PostMapping("/down_or_up")
    public  ResponseResult downOrUp(@RequestBody WmNewsDto dto){
        return wmNewsService.downOrUp(dto);
    }
    @PostMapping("/list_vo")
    public ResponseResult listVo(@RequestBody NewsAuthDto dto){
        return wmNewsService.listVo(dto);
    }
    @GetMapping("/one_vo/{id}")
    public ResponseResult findNewsById(@PathVariable("id") Integer id){
        return wmNewsService.findNewsById(id);
    }
    @PostMapping("/auth_fail")
    public ResponseResult authNewsFail(@RequestBody NewsAuthDto dto){
        return wmNewsService.authNewsFail(dto);
    }
    @PostMapping("/auth_pass")
    public ResponseResult authNewsPass(@RequestBody NewsAuthDto dto){
        return wmNewsService.authNewsPass(dto);
    }
}
